Author: Jonathan Niehof <jtniehof@gmail.com>
Subject: Fix a segfault when parsing options to -buttons
Last-Update: 2009-12-06
Forwarded: yes
Bug: https://sourceforge.net/tracker/?func=detail&aid=2909756&group_id=227783&atid=1072387

joy2key segfaults when reading the list of keystrokes to associate with
buttons. This is a regression from 1.6.1 and this patch simply reverts
the offending line to that earlier version. I have verified that, with
the patch applied, all buttons on the joystick are usable and all buttons
listed on the command line are processed appropriately.

Index: joy2key-1.6.3/joy2key.c
===================================================================
--- joy2key-1.6.3.orig/joy2key.c	2009-12-06 15:38:56.000000000 -0500
+++ joy2key-1.6.3/joy2key.c	2009-12-06 15:50:48.000000000 -0500
@@ -576,7 +576,7 @@
 				exit(1);
 			}
 			button_act_counter=0;
-			while((i+1)<=argc && (argv[i+1][0]!='-' || 
+			while((i+1)<argc && (argv[i+1][0]!='-' || 
 								 (argv[i+1][0]=='-' && !argv[i+1][1])))
 			{
 				button_actions[button_act_counter]=argtokey(argv[++i]);
